<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://www.springframework.org/security/tags" prefix="sec"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Uploaded adverts</title>

</head>
<body>

<table>
	<tbody>
		<c:choose>
   			 <c:when test="${empty adverts}">
       			 <tr/>
       			 <tr/>
       			 <tr>
       			 	<td>
       					 You have no uploaded adverts.
       				</td>
       			 </tr>
  			  </c:when>
   			 <c:otherwise>
   			 	<tr>
					<td>Uploaded adverts</td>
				</tr>
        		<c:forEach items="${adverts}" var="currentAdvert">
					<tr>
						<td>${currentAdvert.title}</td>
						<td>&nbsp;&nbsp;&nbsp;</td>
						<td><a href="${pageContext.request.contextPath}/advertisers/downloadAdvert/${currentAdvert.id}">Download</a></td>
						<td>&nbsp;&nbsp;&nbsp;</td>
						<td><a href="${pageContext.request.contextPath}/adverts/editAdvert/${currentAdvert.id}">Edit</a></td>
						<td>&nbsp;&nbsp;&nbsp;</td>
						<td><a href="${pageContext.request.contextPath}/adverts/deleteAdvert/${currentAdvert.id}">Delete</a></td>
					</tr>
				</c:forEach>
    		</c:otherwise>
		</c:choose>
	</tbody>
</table>

<br><br>
<a href="${pageContext.request.contextPath}/home">Home</a>
</body>
</html>